<?php 

function form2_errors($errors) {
	if (!empty($errors)) {
		return '
		<div class="errors">
			<div class="icon"></div>
			<div class="message">'. $errors .'</div>
		</div>';
	}
}

function form2_input($data) {
	return '
	<div class="el">
		<div class="label">'. form_label($data['label'], $data['name']) . '</div>
		<div class="input input-text">
			'. form_input($data) .'
			<div class="clear"></div>
			<div style="clear: both"></div>
		</div>
		<div style="clear: both"></div>
	</div>';
}

function form2_password($data) {
	return '
	<div class="el">
		<div class="label">'. form_label($data['label'], $data['name']) . '</div>
		<div class="input input-text">
			'. form_password($data) .'
			<div class="clear"></div>
		</div>
		<div style="clear: both"></div>
	</div>';
}

function form2_file($data) {
	return '
	<div class="el">
		<div class="label">'. form_label($data['label'], $data['name']) . '</div>
		<div class="input input-file">
			<div class="c">
				'. form_upload($data) .'
				<input type="text" readonly="true" class="e" />
			</div>
		</div>
		<div style="clear: both"></div>
	</div>';
}

function form2_submit($name, $value) {
	return '<div class="el">
		<div class="input input-button">'
		. form_submit($name, $value) 
		.'</div>
		<div style="clear: both"></div>
	</div>';
}

function form2_select($data) {
	if (!isset($data['name'])) return;
	
	$options = (!isset($data['options'])) ? array() : $data['options'];
	$selected = (!isset($data['selected'])) ? null : $data['selected'];
	
	return '<div class="el">
		<div class="label">'. form_label($data['label'], $data['name']) . '</div>
		<div class="input input-select">
			<div class="c">
				'. form_dropdown($data['name'], $options, $selected) .'
				<input type="text" readonly="true" class="e" />
			</div>
		</div>
		<div style="clear: both"></div>
	</div>';
}

function form2_textarea($data) {
	$c = '<div class="el">';
	
	if (!empty($data['label'])) {
		$c .= '<div class="label">'. form_label($data['label'], $data['name']) . '</div>';
	}
	
	$c .= '<div class="input input-textarea">
			'. form_textarea($data) .'
		</div>
		<div style="clear: both"></div>
	</div>';
	
	return $c;
}